package com.yunxi.service.dubboService.impl.customer;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.yunxi.baseDataToHub.pojo.app.CreditInvestigationAuditVO;
import com.yunxi.baseDataToHub.pojo.app.FinanceAuditVO;
import com.yunxi.baseDataToHub.service.app.AppDubboService;
import com.yunxi.bizToHub.pojo.TPFCreditInvestigationVO;
import com.yunxi.bizToHub.pojo.TPFPatchBoltVO;
import com.yunxi.bizToHub.service.TpfDubboService;
import com.yunxi.core.util.DateUtil;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.customer.pojo.CustomCreditExportVO;
import com.yunxi.customer.pojo.CustomCreditReportingVO;
import com.yunxi.customer.service.CustomCreditReportingDubboService;
import com.yunxi.dealer.pojo.PartnerVO;
import com.yunxi.hubToBaseData.pojo.*;
import com.yunxi.hubToBaseData.service.AppCustomerCredit2PMS;
import com.yunxi.model.customer.CustomCreditReporting;
import com.yunxi.model.sys.Area;
import com.yunxi.order.pojo.OrderCustomerDetailVO;
import com.yunxi.order.pojo.OrderCustomerVO;
import com.yunxi.order.service.OrderCustomerDubboService;
import com.yunxi.service.localService.customer.CustomCreditReportingService;
import com.yunxi.service.localService.dealer.PartnerService;
import com.yunxi.service.localService.sys.AreaService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 个人征信信息表 服务实现类
 * </p>
 *
 * @author
 * @since 2019-08-20
 */
public class CustomCreditReportingDubboServiceImpl implements CustomCreditReportingDubboService, AppCustomerCredit2PMS {

   private static final Logger logger = LoggerFactory.getLogger(CustomCreditReportingDubboServiceImpl.class);

   @Autowired
   @Qualifier(value = "customCreditReportingServiceImpl")
   CustomCreditReportingService customCreditReportingService;

   @Autowired
   AppDubboService appDubboServiceBase;

   @Autowired
   OrderCustomerDubboService orderCustomerDubboServiceBase;

   @Autowired
   @Qualifier(value = "areaServiceImpl")
   AreaService areaService;

   @Autowired
   PartnerService partnerServiceImpl;

   @Autowired
   TpfDubboService tpfDubboServiceBase;

   @Override
   public CustomCreditReportingVO getById(String id) throws Exception {
      CustomCreditReportingVO customCreditReportingVO = new CustomCreditReportingVO();
      if (StringUtils.isNotEmpty(id)) {
         CustomCreditReporting customCreditReporting = customCreditReportingService.getById(id);
         BeanUtils.copyProperties(customCreditReporting, customCreditReportingVO);

         String vehicleName = customCreditReportingService.getVehicleNameByVehicleCode(customCreditReportingVO.getVehicleModel());
         customCreditReportingVO.setVehicleName(vehicleName);
         PartnerVO partnerVO = partnerServiceImpl.getByPartnerCode(customCreditReporting.getFinancingInsitution());
         if (partnerVO!=null){
//         customCreditReportingVO.setFinancingInsitution(partnerVO.getPartnerName());
            customCreditReportingVO.setFinancingInsitutionName(partnerVO.getPartnerName());
         }
//         String vehiclePrice = customCreditReportingService.getVehiclePriceByVehicleCode(customCreditReporting.getVehicleModel(),customCreditReporting.getCreateTime());
         List<String> vehiclePriceList = customCreditReportingService.getVehiclePriceByVehicleCode2(customCreditReporting.getVehicleModel(),customCreditReporting.getCreateTime());
         if (vehiclePriceList!=null && vehiclePriceList.size()>1) throw new Exception("车辆零售指导价存在多条"+customCreditReporting.getVehicleModel()+"_"+customCreditReporting.getCreateTime());
         String vehiclePrice = "";
         if (vehiclePriceList!=null && vehiclePriceList.size()==1) {
            vehiclePrice = vehiclePriceList.get(0);
         }
         //车辆零售价格
         if (StringUtils.isNotEmpty(vehiclePrice)){
            customCreditReportingVO.setVehiclePrice(new BigDecimal(vehiclePrice));
         }
      }
      return customCreditReportingVO;
   }

   /**
    * 审核
    * @param customCreditReportingVO
    * @param loginInfo
    * @return
    */
   @Override
   @Transactional
   public ApiResult saveOrUpdate(CustomCreditReportingVO customCreditReportingVO, LoginInfo loginInfo) {
      //体验车征信审核
      if ("2".equals(customCreditReportingVO.getProductType()) ){
         if (customCreditReportingVO.getVersion()==null) return ResponseUtil.fail(-1,"审核版本为空");
      }
      if (StringUtils.isEmpty(customCreditReportingVO.getCreditId())) return ResponseUtil.fail(-1,"主键为空");
      if (StringUtils.isEmpty(customCreditReportingVO.getLeadsid())) return ResponseUtil.fail(-1,"订单编号为空");

      if (customCreditReportingVO.getApprovalStatus()==null) return ResponseUtil.fail(-1,"审核状态为空");
      if (StringUtils.isEmpty(customCreditReportingVO.getCustomerType())) return ResponseUtil.fail(-1,"征信类型为空");
      OrderCustomerVO orderCustomerVO = orderCustomerDubboServiceBase.getByOrderCustomerNo(customCreditReportingVO.getLeadsid());
      if (StringUtils.isEmpty(orderCustomerVO.getOrderCustomerId())) return ResponseUtil.fail(-1,"不存在该订单:"+customCreditReportingVO.getLeadsid());
      if (orderCustomerVO.getBusType().intValue()==0) return ResponseUtil.fail(-1,"非大定订单客户,暂不能审核"+customCreditReportingVO.getLeadsid());

      CreditInvestigationAuditVO creditInvestigationAuditVO = new CreditInvestigationAuditVO();
      creditInvestigationAuditVO.setOrderNo(customCreditReportingVO.getLeadsid());
      creditInvestigationAuditVO.setVersion(customCreditReportingVO.getVersion());

      //审核状态1待审批，2已通过，3已驳回,4退回补件,5已确认
      //金融方案审核结果返回给app
      FinanceAuditVO financeAuditVO = new FinanceAuditVO();
      if (customCreditReportingVO.getApprovalStatus().intValue()==2){
         creditInvestigationAuditVO.setStatus(1);//1-->通过
         financeAuditVO.setAuditStatus("1");//1-->通过
//         if ("2".equals(customCreditReportingVO.getProductType())){
//            customCreditReportingVO.setApprovalStatus(5);
//         }

      }else if (customCreditReportingVO.getApprovalStatus().intValue()==3){
         creditInvestigationAuditVO.setStatus(2);//2-->拒绝
         financeAuditVO.setAuditStatus("2");//2-->拒绝

      }else if (customCreditReportingVO.getApprovalStatus().intValue()==4){
         creditInvestigationAuditVO.setStatus(3);//3退回补件
         financeAuditVO.setAuditStatus("3");//3退回补件
      }
//      customCreditReportingVO.setCreditCode(GUIDGenerator.getPrimaryKey());
      if (orderCustomerVO.getBuyType()==1){
         setFinanceAuditVO(customCreditReportingVO, financeAuditVO);
         ApiResult result = appDubboServiceBase.sendFinanceAuditPMS2APP(financeAuditVO);
         if (result.getCode() != 200) {
            logger.error("金融方案审核结果返回给app失败，事务回滚!"+result.getMsg());
            return ResponseUtil.fail(-1, "APP执行失败,金融方案审核结果返回给app:" + result.getMsg());
         }
      }else if (orderCustomerVO.getBuyType()==2){
         creditInvestigationAuditVO.setStatementType(Integer.valueOf(customCreditReportingVO.getCustomerType()));
         ApiResult apiResult = appDubboServiceBase.sendCreditInvestigationAuditPMS2APP(creditInvestigationAuditVO);
         if (apiResult.getCode() != 200) {
            logger.error("APP接口执行，征信审核结果传入APP失败，事务回滚!"+apiResult.getMsg());
            return ResponseUtil.fail(-1, "APP执行失败,征信审核结果传入:" + apiResult.getMsg());
         }
      }

      ApiResult result = orderCustomerDubboServiceBase.sendOrderStatus2App(orderCustomerVO,"OC01_FIN_1000","1001");
      if (result!=null) return result;

      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
      BeanUtils.copyProperties(customCreditReportingVO, customCreditReporting);
      customCreditReporting.setApprovalTime(new Date());
//      String financingInsitution = partnerServiceImpl.getPartnerCodeByPartnerName(customCreditReportingVO.getFinancingInsitution());
//      customCreditReporting.setFinancingInsitution(financingInsitution);
      customCreditReportingService.saveOrUpdate(customCreditReporting);
      return ResponseUtil.ok();
   }

   /**
    *
    * 金融方案审核结果返回给app  设置属性
    * @param customCreditReportingVO
    * @param financeAuditVO
    */
   private void setFinanceAuditVO(CustomCreditReportingVO customCreditReportingVO, FinanceAuditVO financeAuditVO) {
      financeAuditVO.setAuditNo(customCreditReportingVO.getCreditCode());
      financeAuditVO.setOrderNo(customCreditReportingVO.getLeadsid());
      financeAuditVO.setBackAttribute(customCreditReportingVO.getBackInfo());
      financeAuditVO.setAuditComment(customCreditReportingVO.getApprovalDesc());
      financeAuditVO.setFinanceInstitutionCode(customCreditReportingVO.getFinancingInsitution());
      financeAuditVO.setLeasePeriod(customCreditReportingVO.getFinTerm());//分期情况
      if (customCreditReportingVO.getDownPaymentRatio()!=null){
         financeAuditVO.setDownPaymentRatio(String.valueOf(customCreditReportingVO.getDownPaymentRatio()));//首付款比例
      }
      if (customCreditReportingVO.getSuretyAmountRatio()!=null){
         financeAuditVO.setMarginLevel(String.valueOf(customCreditReportingVO.getSuretyAmountRatio()));//保证金比例
      }
      if (customCreditReportingVO.getRetentionRatio()!=null){
         financeAuditVO.setReservePriceRatio(String.valueOf(customCreditReportingVO.getRetentionRatio()));//保证金比例
      }
      if (customCreditReportingVO.getRetentionAmount()!=null){
         financeAuditVO.setReservePrice(String.valueOf(customCreditReportingVO.getRetentionAmount()));//保证金比例
      }
      if (customCreditReportingVO.getMonthlyRent()!=null){
         financeAuditVO.setTotalPrice(String.valueOf(customCreditReportingVO.getTransactionPrice()));//总价格
      }
      financeAuditVO.setRate(customCreditReportingVO.getFinancingRate());//利率
      financeAuditVO.setMonthManagePrice(customCreditReportingVO.getMonthManagePrice());//牌照管理费
      financeAuditVO.setDiscountType(customCreditReportingVO.getDiscountType());//贴息类型 1百分比,2固定金额
      financeAuditVO.setDiscountValue(customCreditReportingVO.getDiscountValue());//贴息值
   }

   @Override
   public void removeById(String id) {
      customCreditReportingService.removeById(id);
   }

   @Override
   public PageInfo<CustomCreditReportingVO> findPageByVO(CustomCreditReportingVO customCreditReportingVO, Integer pageNum, Integer pageSize,LoginInfo loginInfo) throws InvocationTargetException, IllegalAccessException {
      if (StringUtils.isNotEmpty(loginInfo.getPartnerCode())){
         //渠道端 金融机构
         if ("roleFinance".equals(loginInfo.getRoleCode()) || "roleBank".equals(loginInfo.getRoleCode()) ){
            customCreditReportingVO.setFinancingInsitution(loginInfo.getPartnerCode());
         }else {
            //渠道端 渠道商
            customCreditReportingVO.setPartnerCode(loginInfo.getPartnerCode());
         }
      }
      PageInfo<CustomCreditReportingVO> pageInfo = customCreditReportingService.pageByVo(customCreditReportingVO, pageNum, pageSize);
      return pageInfo;
   }

   @Override
   public void removeByListVo(List<CustomCreditReportingVO> customCreditReportingVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
      customCreditReportingService.removeByListVo(customCreditReportingVOList);
   }

   @Override
   public List listByVo(CustomCreditReportingVO customCreditReportingVO) {
      return customCreditReportingService.listByVo(customCreditReportingVO);
   }

   @Override
   @Transactional
   public ApiResult updateBatch(List<CustomCreditReportingVO> list,LoginInfo loginInfo) {
      ApiResult result =null;
      if (list != null && list.size() > 0) {
         for (CustomCreditReportingVO customCreditReportingVO : list) {
            result= this.saveOrUpdate(customCreditReportingVO,loginInfo);
         }
      }
      return result;
   }

   /**
    * 获得导出数据
    *
    * @param voList
    * @return
    */
   @Override
   public List<CustomCreditExportVO> exportDetailDate(List<CustomCreditReportingVO> voList) {
      ArrayList<CustomCreditExportVO> customCreditExportVOS = new ArrayList<>();
      if (voList != null && voList.size() > 0) {
         for (CustomCreditReportingVO customCreditReportingVO : voList) {
            List<CustomCreditReportingVO> list = customCreditReportingService.listByVo(customCreditReportingVO);
            if (list != null && list.size() > 0) {
               for (CustomCreditReportingVO creditReportingVO : list) {
                  CustomCreditExportVO customCreditExportVO = new CustomCreditExportVO();
                  BeanUtils.copyProperties(creditReportingVO, customCreditExportVO);

                  convertProp(creditReportingVO, customCreditExportVO);

                  if (StringUtils.isNotEmpty(creditReportingVO.getVehicleModel())){
                     String name = customCreditReportingService.getVehicleNameByVehicleCode(creditReportingVO.getVehicleModel());
                     customCreditExportVO.setVehicleModel(name);
                  }
                  PartnerVO partnerVO = partnerServiceImpl.getByPartnerCode(creditReportingVO.getFinancingInsitution());
                  if (partnerVO!=null){
                     customCreditExportVO.setFinancingInsitution(partnerVO.getPartnerName());
                  }
                  customCreditExportVOS.add(customCreditExportVO);
               }
            }
         }
      }
      return customCreditExportVOS;
   }

   @Override
   public List<CustomCreditReportingVO> getByOrderCustomerNo(String orderCustomerNo) {
      return customCreditReportingService.getByOrderCustomerNo(orderCustomerNo);
   }

   private void convertProp(CustomCreditReportingVO creditReportingVO, CustomCreditExportVO customCreditExportVO) {
      if ("1".equals(creditReportingVO.getFinProduct())){
         customCreditExportVO.setCustomerType("金融机构");
      }else if ("2".equals(creditReportingVO.getFinProduct())){
         customCreditExportVO.setCustomerType("银行分期");
      }

      if ("1".equals(creditReportingVO.getCustomerType())){
         customCreditExportVO.setCustomerType("个人");
      }else if ("2".equals(creditReportingVO.getCustomerType())){
         customCreditExportVO.setCustomerType("企业");
      }

      if (creditReportingVO.getApprovalStatus()!=null){
         if (creditReportingVO.getApprovalStatus()==1){
            customCreditExportVO.setApprovalStatus("待审批");
         }else if (creditReportingVO.getApprovalStatus()==2){
            customCreditExportVO.setApprovalStatus("已通过");
         }else if (creditReportingVO.getApprovalStatus()==3){
            customCreditExportVO.setApprovalStatus("已拒绝");
         }else if (creditReportingVO.getApprovalStatus()==4){
            customCreditExportVO.setApprovalStatus("退回补件");
         }else if (creditReportingVO.getApprovalStatus()==5){
            customCreditExportVO.setApprovalStatus("用户已确认");
         }else if (creditReportingVO.getApprovalStatus()==6){
            customCreditExportVO.setApprovalStatus("用户已拒绝");
         }
      }

      if (StringUtils.isNotEmpty(creditReportingVO.getGender()) ){
         if ("1".equals(creditReportingVO.getGender()) ){
            customCreditExportVO.setGender("男");
         }else if ("2".equals(creditReportingVO.getGender())){
            customCreditExportVO.setGender("女");
         }
      }

      if (creditReportingVO.getMaritalStatus()!=null){
         if (creditReportingVO.getMaritalStatus()==1){
            customCreditExportVO.setMaritalStatus("未婚");
         }else if (creditReportingVO.getMaritalStatus()==2){
            customCreditExportVO.setMaritalStatus("已婚");
         }else if (creditReportingVO.getMaritalStatus()==3){
            customCreditExportVO.setMaritalStatus("丧偶");
         }else if (creditReportingVO.getMaritalStatus()==3){
            customCreditExportVO.setMaritalStatus("离异");
         }
      }

      if (creditReportingVO.getIdCertType()!=null){
         if (creditReportingVO.getIdCertType()==1){
            customCreditExportVO.setIdCertType("身份证");
         }else if (creditReportingVO.getIdCertType()==2){
            customCreditExportVO.setIdCertType("军官证");
         }else if (creditReportingVO.getIdCertType()==3){
            customCreditExportVO.setIdCertType("港澳台海外地区证件");
         }else if (creditReportingVO.getIdCertType()==4){
            customCreditExportVO.setIdCertType("企业代码证");
         }else if (creditReportingVO.getIdCertType()==5){
            customCreditExportVO.setIdCertType("驾驶证");
         }
      }


      if ("2".equals(creditReportingVO.getProductType())){
         customCreditExportVO.setProductType("体验车");
      }else if ("3".equals(creditReportingVO.getProductType())){
         customCreditExportVO.setProductType("畅享车");
      }else if ("1".equals(creditReportingVO.getProductType())){
         customCreditExportVO.setProductType("购车");
      }

      if (customCreditExportVO.getCreateTime()!=null){
         customCreditExportVO.setCreateTimeStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(customCreditExportVO.getCreateTime()));
      }

      if ("1".equals(creditReportingVO.getCompanyLegalGender())){
         customCreditExportVO.setCompanyLegalGender("男");
      }else if ("2".equals(creditReportingVO.getCompanyLegalGender())){
         customCreditExportVO.setCompanyLegalGender("女");
      }

      if ("1".equals(creditReportingVO.getIsLicense())){
         customCreditExportVO.setIsLicense("是");
      }else if ("0".equals(creditReportingVO.getIsLicense())){
         customCreditExportVO.setIsLicense("否");
      }

      if ("1".equals(creditReportingVO.getUrgencyrelation())){
         customCreditExportVO.setUrgencyrelation("父母或子女");
      }else  if ("2".equals(creditReportingVO.getUrgencyrelation())){
         customCreditExportVO.setUrgencyrelation("朋友或同事");
      }else  if ("3".equals(creditReportingVO.getUrgencyrelation())){
         customCreditExportVO.setUrgencyrelation("其他亲属");
      }

      if ("1".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("自置");
      }else if ("2".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("按揭");
      }else if ("3".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("集体宿舍");
      }else if ("4".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("租房");
      }else if ("5".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("共有住宅");
      }else if ("6".equals(creditReportingVO.getPropertystatus())){
         customCreditExportVO.setPropertystatus("其他");
      }

      if ("1".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("国有企业");
      }else if ("2".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("外资企业");
      }else if ("3".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("小微企业");
      }else if ("4".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("上市民营企业");
      }else if ("5".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("非上市民营企业");
      }else if ("6".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("政府机关");
      }else if ("7".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("事业单位");
      }else if ("8".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("知名跨国公司");
      }else if ("9".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("个体户");
      }else if ("10".equals(creditReportingVO.getCompanytype())){
         customCreditExportVO.setCompanytype("自由职业及其他");
      }

      if ("1".equals(creditReportingVO.getSuretyRelation())){
         customCreditExportVO.setSuretyRelation("父母或子女");
      }else  if ("2".equals(creditReportingVO.getSuretyRelation())){
         customCreditExportVO.setSuretyRelation("朋友或同事");
      }else  if ("3".equals(creditReportingVO.getSuretyRelation())){
         customCreditExportVO.setSuretyRelation("其他亲属");
      }

      if ("1".equals(creditReportingVO.getCompanyRelation())){
         customCreditExportVO.setCompanyRelation("父母或子女");
      }else  if ("2".equals(creditReportingVO.getCompanyRelation())){
         customCreditExportVO.setCompanyRelation("朋友或同事");
      }else  if ("3".equals(creditReportingVO.getCompanyRelation())){
         customCreditExportVO.setCompanyRelation("其他亲属");
      }

      if ("1".equals(creditReportingVO.getFinProduct())){
         customCreditExportVO.setFinProduct("金融机构");
      }else  if ("2".equals(creditReportingVO.getFinProduct())){
         customCreditExportVO.setFinProduct("银行分期");
      }

      if ("1".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("研究生");
      }else  if ("2".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("大学本科");
      }else  if ("3".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("大学专科");
      }else  if ("4".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("中等专科");
      }else  if ("5".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("高中");
      }else  if ("6".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("初中");
      }else  if ("7".equals(creditReportingVO.getEducation())){
         customCreditExportVO.setEducation("初中以下");
      }
   }



//   /**
//    * 进件
//    * 接收客户征信信息
//    *
//    * @param customerCreditVO
//    * @return
//    */
//   @Override
//   public ApiResult AppCustomerCredit2PMS(CustomerCreditVO customerCreditVO) {
//
//      CustomCreditReportingVO customCreditReportingVO = setCustomCreditReportingVO(customerCreditVO);
//      customCreditReportingVO.setCreateBy("youjia");
//      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
//      BeanUtils.copyProperties(customCreditReportingVO, customCreditReporting);
//      customCreditReportingService.saveOrUpdate(customCreditReporting);
//      return ResponseUtil.ok();
//   }

//   /**
//    * 补件
//    *
//    * @param customerCreditSupplementVO
//    * @return
//    */
//   @Override
//   public ApiResult AppCustomerCreditSupplement2PMS(CustomerCreditSupplementVO customerCreditSupplementVO) {
//      CustomCreditReportingVO customCreditReportingVO = new CustomCreditReportingVO();
//      customCreditReportingVO.setLeadsid(customerCreditSupplementVO.getLeadsid());//订单编号
//      List<CustomCreditReporting> list = customCreditReportingService.listByVo(customCreditReportingVO);
//      if (list != null && list.size() > 0) {
//         customCreditReportingVO.setCreditId(list.get(0).getCreditId());
//      }
//      customCreditReportingVO.setPhone(customerCreditSupplementVO.getMobilenumber());//手机
//      customCreditReportingVO.setSourceType(customerCreditSupplementVO.getSourceType());//渠道源
//      customCreditReportingVO.setImagepath(customerCreditSupplementVO.getImagepath());//图像相对路径
//
//      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
//      BeanUtils.copyProperties(customCreditReportingVO, customCreditReporting);
//      customCreditReportingService.updateById(customCreditReporting);
//
//
//      return null;
//   }

   /**
    * 征信数据上传
    * APP->PMS
    * @param
    * @return
    */
   @Override
   @Transactional
   public ApiResult AppCustomerCredit2PMS(CustomerCreditAppVO customerCreditAppVO)  {
      if (customerCreditAppVO.getStatementType()==null) return ResponseUtil.fail(-1,"征信类型为空");
      if (customerCreditAppVO.getStatementType().intValue()==1){
         if (customerCreditAppVO.getPersonInfo()==null) return ResponseUtil.fail(-1,"征信类型"+customerCreditAppVO.getStatementType()+"个人信息为空");
         if (StringUtils.isEmpty(customerCreditAppVO.getPersonInfo().getName())) return ResponseUtil.fail(-1,"姓名为空");
         if (StringUtils.isEmpty(customerCreditAppVO.getPersonInfo().getMobile())) return ResponseUtil.fail(-1,"电话为空");
      }else {
         if (customerCreditAppVO.getCompanyInfo()==null) return ResponseUtil.fail(-1,"征信类型"+customerCreditAppVO.getStatementType()+"企业信息为空");
         if (StringUtils.isEmpty(customerCreditAppVO.getCompanyInfo().getCompanyName())) return ResponseUtil.fail(-1,"企业名称为空");
         if (StringUtils.isEmpty(customerCreditAppVO.getCompanyInfo().getContactPhone())) return ResponseUtil.fail(-1,"企业联系人手机为空");
      }
      if (customerCreditAppVO.getVersion()==null) return ResponseUtil.fail(-1,"审核版本为空");
      if (StringUtils.isEmpty(customerCreditAppVO.getOrderNo()) ) return ResponseUtil.fail(-1,"订单编号为空");
      //订单信息
      OrderCustomerVO orderCustomerVO = orderCustomerDubboServiceBase.getByOrderCustomerNo(customerCreditAppVO.getOrderNo());
      if (StringUtils.isEmpty(orderCustomerVO.getOrderCustomerId())) return ResponseUtil.fail(-1,"不存在该订单"+customerCreditAppVO.getOrderNo());
      if ("1".equals(orderCustomerVO.getIsUpload()))  return ResponseUtil.fail(-1,"该订单已上传合同照片,征信数据无法上传"+customerCreditAppVO.getOrderNo());
      if (orderCustomerVO.getBusType().intValue() != 1) return ResponseUtil.fail(-1,"该订单非大定订单,征信数据无法上传"+customerCreditAppVO.getOrderNo());
      if (orderCustomerVO.getIsCancel().intValue() == 1) return ResponseUtil.fail(-1,"该订单已发起退订,征信数据无法上传"+customerCreditAppVO.getOrderNo());
      if (orderCustomerVO.getBuyType()==1) return ResponseUtil.fail(-1,"购车方案为购车,征信数据无法上传");

      //第一个版本没结束不能提交第二个版本到PMS
      QueryWrapper<CustomCreditReporting> queryWrapper = new QueryWrapper<>();
      HashMap<String, Object> map1 = new HashMap<>();
      map1.put("LEADSID",customerCreditAppVO.getOrderNo());
      Integer vers = customerCreditAppVO.getVersion();
      int j = vers.intValue();
      map1.put("VERSION", j);
      queryWrapper.allEq(map1);
      List<CustomCreditReporting> creditReportingList = customCreditReportingService.list(queryWrapper);
      if (creditReportingList!=null && creditReportingList.size()>0) return ResponseUtil.fail(-1,"当前客户征信版本已存在");

      QueryWrapper<CustomCreditReporting> wrapper = new QueryWrapper<>();
      HashMap<String, Object> map = new HashMap<>();
      map.put("LEADSID",customerCreditAppVO.getOrderNo());
      Integer version = customerCreditAppVO.getVersion();
      int i = version.intValue();
      map.put("VERSION", i-1);
      wrapper.allEq(map);
      List<CustomCreditReporting> list = customCreditReportingService.list(wrapper);
      if (list!=null && list.size()>0) {
         CustomCreditReporting creditReporting = list.get(0);
         if (creditReporting.getApprovalStatus().intValue()==1) return ResponseUtil.fail(-1,"当前客户征信审核中");
         if (creditReporting.getApprovalStatus().intValue()==2) return ResponseUtil.fail(-1,"当前客户征信用户审批通过");
//         if (creditReporting.getApprovalStatus().intValue()==3) return ResponseUtil.fail(-1,"当前客户征信已拒绝");
//         if (creditReporting.getApprovalStatus().intValue()==5) return ResponseUtil.fail(-1,"当前客户征信用户已确认");
//         if (creditReporting.getApprovalStatus().intValue()==6) return ResponseUtil.fail(-1,"当前客户征信用户已拒绝");
      }

      CustomCreditReportingVO customCreditReportingVO = setCreditProp(customerCreditAppVO,orderCustomerVO);
      if (orderCustomerVO.getBuyType()==2){
         //默认选择第一个金融机构
         PartnerVO partnerVO = partnerServiceImpl.getByBusinessCode("010");
         if (partnerVO!=null && StringUtils.isNotEmpty(partnerVO.getPartnerId())){
            customCreditReportingVO.setFinancingInsitution(partnerVO.getPartnerCode());
         }else {
            return ResponseUtil.fail(-1,"不存在金融机构信息");
         }
      }
      if (StringUtils.isEmpty(customCreditReportingVO.getProvince())) return ResponseUtil.fail(-1,"省或市为空");
//      if (StringUtils.isEmpty(customCreditReportingVO.getFinancingInsitution())) return ResponseUtil.fail(-1,"不存在金融公司");
      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
      BeanUtils.copyProperties(customCreditReportingVO, customCreditReporting);
      customCreditReportingService.saveOrUpdate(customCreditReporting);

      return ResponseUtil.ok();
   }

   /**
    * 金融方案用户确认/拒绝 结果返回
    * APP->PMS
    * @param
    * @return
    */
   @Override
   @Transactional
   public ApiResult AppCustomerConfirmCredit2PMS(CustomerCreditResultVO customerCreditResultVO) throws Exception {
      //auditStatus;//审核状态 1.用户已确认 2.用户已拒绝

      QueryWrapper<CustomCreditReporting> queryWrapper = new QueryWrapper<>();
      HashMap<String, Object> map = new HashMap<>();
      map.put("CREDIT_CODE",customerCreditResultVO.getAuditNo());//审核流水号
      map.put("LEADSID",customerCreditResultVO.getOrderNo());//订单号
      queryWrapper.allEq(map);
      CustomCreditReporting customCreditReporting = new CustomCreditReporting();

      //用户确认
      if ("1".equals(customerCreditResultVO.getAuditStatus())){
         customCreditReporting.setApprovalStatus(5);
      //用户拒绝
      }else if ("2".equals(customerCreditResultVO.getAuditStatus())){
         customCreditReporting.setApprovalStatus(6);
      }

      List<CustomCreditReporting> list = customCreditReportingService.list(queryWrapper);
      if (list==null || list.size()<=0) return ResponseUtil.fail(-1,"审核流水号或订单编号不存在");
      CustomCreditReporting reporting = list.get(0);
      if (reporting.getApprovalStatus().intValue()==1) return ResponseUtil.fail(-1,"当前金融方案待审核");
      customCreditReportingService.update(customCreditReporting,queryWrapper);

      return ResponseUtil.ok();
   }

   /**
    * 金融方案提交接口
    * APP->PMS
    * @param
    * @return
    */
   @Override
   @Transactional
   public ApiResult AppCreditFinancialPlan2PMS(CustomerCreditFinancialPlanVO customerCreditFinancialPlanVO) {
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getOrderNo())) return ResponseUtil.fail(-1,"订单编号为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getFinanceInstitutionCode())) return ResponseUtil.fail(-1,"金融机构编号为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getAuditNo())) return ResponseUtil.fail(-1,"审核流水号为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getAuditType())) return ResponseUtil.fail(-1,"征信审核类型为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getFinanceType())) return ResponseUtil.fail(-1,"金融类型为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getPaymentType())) return ResponseUtil.fail(-1,"支付方式为空");
      if ("1".equals(customerCreditFinancialPlanVO.getPaymentType())) return ResponseUtil.fail(-1,"全款购车不存在金融方案"+customerCreditFinancialPlanVO.getPaymentType());
      if (!"2".equals(customerCreditFinancialPlanVO.getPaymentType())) return ResponseUtil.fail(-1,"金融方案支付方式错误"+customerCreditFinancialPlanVO.getPaymentType());

      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getLeasePeriod())) return ResponseUtil.fail(-1,"分期为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getDownPaymentRatio())) return ResponseUtil.fail(-1,"首付款比例为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getMarginLevel())) return ResponseUtil.fail(-1,"保证金比例为空");
//      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getReservePriceRatio()) && StringUtils.isEmpty(customerCreditFinancialPlanVO.getReservePrice())) return ResponseUtil.fail(-1,"留购价比例或留购价金额为空");
//      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getReservePriceRatio()) && StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getReservePrice())) return ResponseUtil.fail(-1,"留购价比例,留购价金额请选择一种");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getTotalPrice())) return ResponseUtil.fail(-1,"总价格为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getRate()) && StringUtils.isEmpty(customerCreditFinancialPlanVO.getTariff())) return ResponseUtil.fail(-1,"利率为空或费率为空");
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getRate()) && StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getTariff())) return ResponseUtil.fail(-1,"利率,费率请选择一种");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getDiscountType())) return ResponseUtil.fail(-1,"贴息类型为空");
      if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getDiscountValue())) return ResponseUtil.fail(-1,"贴息值为空");

      OrderCustomerVO orderCustomerVO = orderCustomerDubboServiceBase.load(customerCreditFinancialPlanVO.getOrderNo());
      if (orderCustomerVO ==null || StringUtils.isEmpty(orderCustomerVO.getOrderCustomerId())) return ResponseUtil.fail(-1,"不存在该订单"+customerCreditFinancialPlanVO.getOrderNo());
      if ("1".equals(orderCustomerVO.getIsUpload()))  return ResponseUtil.fail(-1,"该订单已上传合同照片,无法提交金融方案"+customerCreditFinancialPlanVO.getOrderNo());
      if (orderCustomerVO.getBusType().intValue() != 1) return ResponseUtil.fail(-1,"该订单非大定订单,无法提交金融方案"+customerCreditFinancialPlanVO.getOrderNo());
      if (orderCustomerVO.getIsCancel().intValue() == 1) return ResponseUtil.fail(-1,"该订单已发起退订,无法提交金融方案"+customerCreditFinancialPlanVO.getOrderNo());
      if (orderCustomerVO.getBuyType().intValue() == 2) return ResponseUtil.fail(-1,"该订单为体验车,无法提交金融方案"+customerCreditFinancialPlanVO.getOrderNo());
//      if ("P19120906".equals(customerCreditFinancialPlanVO.getFinanceInstitutionCode())) return ResponseUtil.fail(-1,"晋城银行暂不可推送");
      if ("P19120906".equals(customerCreditFinancialPlanVO.getFinanceInstitutionCode()) && "2".equals(customerCreditFinancialPlanVO.getAuditType())) return ResponseUtil.fail(-1,"晋城银行不存在企业类型:"+customerCreditFinancialPlanVO.getAuditType());

      QueryWrapper<CustomCreditReporting> queryWrapper = new QueryWrapper<>();
      HashMap<String, Object> map = new HashMap<>();
//      map.put("CREDIT_CODE",customerCreditFinancialPlanVO.getAuditNo());//审核流水号
      map.put("LEADSID",customerCreditFinancialPlanVO.getOrderNo());//订单号
      queryWrapper.allEq(map);
      queryWrapper.orderByDesc("CREATE_TIME");
      List<CustomCreditReporting> list = customCreditReportingService.list(queryWrapper);
      CustomCreditReporting creditReporting = null;
      if (list!=null && list.size()>0) {
         creditReporting = list.get(0);
         if (creditReporting.getApprovalStatus().intValue()==1) return ResponseUtil.fail(-1,"当前金融方案审核中");
         if (creditReporting.getApprovalStatus().intValue()==2) return ResponseUtil.fail(-1,"当前金融方案审批通过,待用户确认");
         if (creditReporting.getApprovalStatus().intValue()==5) return ResponseUtil.fail(-1,"当前金融方案用户已确认");
         if (creditReporting.getApprovalStatus().intValue()==4){
            if (!customerCreditFinancialPlanVO.getFinanceInstitutionCode().equals(creditReporting.getFinancingInsitution())){
               return ResponseUtil.fail(-1,"退回补件金融机构不一致"+customerCreditFinancialPlanVO.getFinanceInstitutionCode());
            }
         }
      }

      for (CustomCreditReporting reporting : list) {
         if (customerCreditFinancialPlanVO.getFinanceInstitutionCode().equals(reporting.getFinancingInsitution())){
            if (creditReporting.getApprovalStatus().intValue()==3) return ResponseUtil.fail(-1,"当前金融机构,金融方案审批拒绝");
            if (creditReporting.getApprovalStatus().intValue()==6) return ResponseUtil.fail(-1,"当前金融机构,金融方案用户已拒绝");
         }
      }

      String accountGroupCode =  partnerServiceImpl.getAccountGroupCode(customerCreditFinancialPlanVO.getFinanceInstitutionCode());
      if ("1".equals(customerCreditFinancialPlanVO.getFinanceType())){
         if (!"F01".equals(accountGroupCode)) return ResponseUtil.fail(-1,"该机构非金融机构"+customerCreditFinancialPlanVO.getFinanceInstitutionCode());
      }else if ("2".equals(customerCreditFinancialPlanVO.getFinanceType())){
         if (!"B01".equals(accountGroupCode)) return ResponseUtil.fail(-1,"该机构非银行机构"+customerCreditFinancialPlanVO.getFinanceInstitutionCode());
      }

      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
      if (creditReporting!=null && StringUtils.isNotEmpty(creditReporting.getCreditId())){
         if (customerCreditFinancialPlanVO.getFinanceInstitutionCode().equals(creditReporting.getFinancingInsitution())){
            customCreditReporting.setCreditId(creditReporting.getCreditId());
         }
      }

      setFinInfo(customerCreditFinancialPlanVO,orderCustomerVO, customCreditReporting);
      customCreditReportingService.saveOrUpdate(customCreditReporting);

      //金融code是晋城银行
      if ("P19120906".equals(customerCreditFinancialPlanVO.getFinanceInstitutionCode())){
         if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getIdCardPicFront())) return ResponseUtil.fail(-1,"身份证正面为空");
         if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getIdCardPicBack())) return ResponseUtil.fail(-1,"身份证反面为空");
         if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getDrivingLicensePicFront())) return ResponseUtil.fail(-1,"驾驶证正面为空");
         if (StringUtils.isEmpty(customerCreditFinancialPlanVO.getDrivingLicensePicBack())) return ResponseUtil.fail(-1,"驾驶证正面为空");
         if (creditReporting==null){
            TPFCreditInvestigationVO tpfCreditInvestigationVO = setTPFCreditInfo(customerCreditFinancialPlanVO, orderCustomerVO);
            //PMS系统进件信息给有车有家系统
            ApiResult result = tpfDubboServiceBase.sendCreditInvestigationPms2YCYJ(tpfCreditInvestigationVO);
            if (result.getCode() != 200) {
               TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
               logger.error("有车有家系统执行失败，PMS系统进件信息同步有车有家系统失败，事务回滚!"+result.getMsg());
               return ResponseUtil.fail(-1, "有车有家系统执行失败,PMS系统进件信息同步有车有家系统失败:" + result.getMsg());
            }
         }
         if (creditReporting!=null && creditReporting.getApprovalStatus().intValue()==4){
            //PMS系统传递补件信息给有车有家系统
            if (creditReporting.getApprovalStatus().intValue()==4){
               TPFPatchBoltVO tpfPatchBoltVO = new TPFPatchBoltVO();
               tpfPatchBoltVO.setLeadsid(customerCreditFinancialPlanVO.getOrderNo());//订单编号
               tpfPatchBoltVO.setMobilenumber(customerCreditFinancialPlanVO.getPhoneNo());//手机
               tpfPatchBoltVO.setSourceType("18");//渠道源
               String idCardPicFront = customerCreditFinancialPlanVO.getIdCardPicFront();
               String idCardPicBack = customerCreditFinancialPlanVO.getIdCardPicBack();
               String drivingLicensePicFront = customerCreditFinancialPlanVO.getDrivingLicensePicFront();
               String drivingLicensePicBack = customerCreditFinancialPlanVO.getDrivingLicensePicBack();
               String imagepath = idCardPicFront+","+idCardPicBack+","+drivingLicensePicFront+","+drivingLicensePicBack;
               tpfPatchBoltVO.setImagepath(imagepath);//图像相对路径
               ApiResult apiResult = tpfDubboServiceBase.sendPatchBoltVOPms2YCYJ(tpfPatchBoltVO);
               if (apiResult.getCode() != 200) {
                  TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                  logger.error("有车有家系统执行失败，PMS系统传递补件信息给有车有家系统失败，事务回滚!"+apiResult.getMsg());
                  return ResponseUtil.fail(-1, "有车有家系统执行失败,PMS系统传递补件信息给有车有家系统失败:" + apiResult.getMsg());
               }
            }
         }
      }


      return ResponseUtil.ok();
   }

   /**
    * YCYJ同步订单金融方案审核信息=>PMS
    * @param
    * @return
    */
   @Override
   public ApiResult YCYJSyncOrderInfo2PMS(OrderInfoVO orderInfoVO) {
      if (!"10".equals(orderInfoVO.getApprovalStatus()) && !"20".equals(orderInfoVO.getApprovalStatus()) && !"90".equals(orderInfoVO.getApprovalStatus())){
         return ResponseUtil.fail(-1,"同步订单信息,状态码不存在:"+orderInfoVO.getApprovalStatus());
      }
      List<CustomCreditReportingVO> list = customCreditReportingService.getByOrderCustomerNo(orderInfoVO.getOrderId());
      if (list==null || list.size()<=0) return ResponseUtil.fail(-1,"不存在该金融方案");
      CustomCreditReportingVO customCreditReportingVO = list.get(0);
      if (customCreditReportingVO.getApprovalStatus()==2) return ResponseUtil.fail(-1,"当前方案审核已通过,不可再次提交");
      if (customCreditReportingVO.getApprovalStatus()==3) return ResponseUtil.fail(-1,"当前方案审核已拒绝,不可再次提交");
      if (customCreditReportingVO.getApprovalStatus()==4) return ResponseUtil.fail(-1,"当前方案审核已退回补件,不可再次提交");

      FinanceAuditVO financeAuditVO = new FinanceAuditVO();
      StringBuffer sb = new StringBuffer();
      if ("20".equals(orderInfoVO.getApprovalStatus())){
         financeAuditVO.setAuditStatus("1");//1-->通过
         customCreditReportingVO.setApprovalStatus(2);
      }else if ("90".equals(orderInfoVO.getApprovalStatus())){
         financeAuditVO.setAuditStatus("2");//2-->拒绝
         customCreditReportingVO.setApprovalStatus(3);
      }else if ("10".equals(orderInfoVO.getApprovalStatus())){
         financeAuditVO.setAuditStatus("3");//3退回补件
         customCreditReportingVO.setApprovalStatus(4);
         if (StringUtils.isEmpty(orderInfoVO.getRequireList())) {
            return ResponseUtil.fail(-1,"退回补件项为空");
         }else {
            String requireList = orderInfoVO.getRequireList();
            if (StringUtils.isNotEmpty(requireList)){
               String[] split = requireList.split(",");
               for (int i = 0; i < split.length; i++) {
                  String s = split[i];
                  if ("1".equals(s)){
                     //客户驾照 （主页，副页）
                     sb.append("drivingLicensePicFront");
                     if (i!=split.length-1){
                        sb.append(",");
                     }
                  } else if ("3".equals(s)){
                     //客户身份证 （正面，反面）
                     sb.append("idCardPicFront");
                     if (i!=split.length-1){
                        sb.append(",");
                     }
                  }else {
                     sb.append(s);
                     if (i!=split.length-1){
                        sb.append(",");
                     }
                  }
               }
               customCreditReportingVO.setBackInfo(sb.toString());
            }
         }
      }

      setFinanceAuditVO(customCreditReportingVO, financeAuditVO);
      ApiResult result = appDubboServiceBase.sendFinanceAuditPMS2APP(financeAuditVO);
      if (result.getCode() != 200) {
         logger.error("有车有家金融方案审核结果返回给app失败，事务回滚!"+result.getMsg());
         return ResponseUtil.fail(-1, "APP执行失败,有车有家金融方案审核结果返回给app:" + result.getMsg());
      }

      CustomCreditReporting customCreditReporting = new CustomCreditReporting();
      BeanUtils.copyProperties(customCreditReportingVO, customCreditReporting);
      String approvalTime = orderInfoVO.getApprovalTime();
      if (StringUtils.isNotEmpty(approvalTime)){
         customCreditReporting.setApprovalTime(DateUtil.parse(approvalTime));
      }
      customCreditReportingService.saveOrUpdate(customCreditReporting);
      return ResponseUtil.ok();
   }

   private TPFCreditInvestigationVO setTPFCreditInfo(CustomerCreditFinancialPlanVO customerCreditFinancialPlanVO, OrderCustomerVO orderCustomerVO) {
      TPFCreditInvestigationVO tpfCreditInvestigationVO = new TPFCreditInvestigationVO();
      tpfCreditInvestigationVO.setLeadsid(customerCreditFinancialPlanVO.getOrderNo());//订单编号
      tpfCreditInvestigationVO.setMobilenumber(customerCreditFinancialPlanVO.getPhoneNo());//手机
      tpfCreditInvestigationVO.setIdentitynumber(customerCreditFinancialPlanVO.getCertNo());//身份证
      tpfCreditInvestigationVO.setName(customerCreditFinancialPlanVO.getUserName());//姓名
      tpfCreditInvestigationVO.setSourceType("18");//渠道源
      tpfCreditInvestigationVO.setVehiclebrand("爱驰");//车品牌
      OrderCustomerDetailVO orderCustomerDetailVO = orderCustomerVO.getOrderCustomerDetailVO();
      String vehicletype = "";
      String vehicleName = "";
      if (StringUtils.isNotEmpty(orderCustomerDetailVO.getVehicleName())){
         String[] split = orderCustomerDetailVO.getVehicleName().split("/");
         vehicletype = split[0];
         vehicleName = split[1];
      }
      tpfCreditInvestigationVO.setVehiclemodel(vehicleName);//车型
      tpfCreditInvestigationVO.setVehiclemodelid(orderCustomerDetailVO.getVehicleCode());//车型id
      String vehiclePrice = customCreditReportingService.getVehiclePriceByVehicleCode(orderCustomerDetailVO.getVehicleCode(),orderCustomerVO.getCreateTime());

      tpfCreditInvestigationVO.setVehiclemsrp(vehiclePrice);//指导价
      tpfCreditInvestigationVO.setVehicletype(vehicletype);//车系
      tpfCreditInvestigationVO.setType("1");//车辆状态 例：“1”；说明：1：新车 2：二手车
      tpfCreditInvestigationVO.setAdviceamount("");//建议额度
      tpfCreditInvestigationVO.setAgerange("");//车龄
      tpfCreditInvestigationVO.setBankslip("");//银行流水
      tpfCreditInvestigationVO.setCompanytype(customerCreditFinancialPlanVO.getEnterpriseType());//企业类型
      tpfCreditInvestigationVO.setCreditcardstatus("");//信用卡情况
      tpfCreditInvestigationVO.setDebtcardstatus("");//银行卡情况
      tpfCreditInvestigationVO.setDelqstatus("");//逾期情况
      tpfCreditInvestigationVO.setDocumentuploading("");//用户资料是否上传

      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getTotalPrice()) && StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getDownPaymentRatio())){
         BigDecimal totalPrice = new BigDecimal(customerCreditFinancialPlanVO.getTotalPrice());
         BigDecimal downPaymentRatio = new BigDecimal(customerCreditFinancialPlanVO.getDownPaymentRatio());
         BigDecimal downpaymentpct = totalPrice.multiply(downPaymentRatio);
         String s = downpaymentpct.toString();
         tpfCreditInvestigationVO.setDownpaymentpct(s);//首付款
      }


      tpfCreditInvestigationVO.setFinAmount("");//融资金额
      tpfCreditInvestigationVO.setFinProduct("1");//金融产品
      tpfCreditInvestigationVO.setFinTerm(customerCreditFinancialPlanVO.getLeasePeriod());//分期情况
      tpfCreditInvestigationVO.setGender(customerCreditFinancialPlanVO.getGender());
      String idCardPicFront = customerCreditFinancialPlanVO.getIdCardPicFront();
      String idCardPicBack = customerCreditFinancialPlanVO.getIdCardPicBack();
      String drivingLicensePicFront = customerCreditFinancialPlanVO.getDrivingLicensePicFront();
      String drivingLicensePicBack = customerCreditFinancialPlanVO.getDrivingLicensePicBack();
      String imagepath = idCardPicFront+","+idCardPicBack+","+drivingLicensePicFront+","+drivingLicensePicBack;
      tpfCreditInvestigationVO.setImagepath(imagepath);//图像相对路径
      tpfCreditInvestigationVO.setIntention("");//客户意愿
      tpfCreditInvestigationVO.setLeadschannel("OEM-爱驰");//渠道
      if (orderCustomerVO.getCreateTime()!=null){
         String orderCreateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(orderCustomerVO.getCreateTime());
         tpfCreditInvestigationVO.setLeadstime(orderCreateTime);//订单创建时间
      }
      tpfCreditInvestigationVO.setMortgagestatus("");//房贷情况
      tpfCreditInvestigationVO.setPropertystatus(customerCreditFinancialPlanVO.getResidentialStatus());//住房情况
      tpfCreditInvestigationVO.setResidencystatus(customerCreditFinancialPlanVO.getAddress());//户口
      tpfCreditInvestigationVO.setSalary("");//月薪
      tpfCreditInvestigationVO.setScore("");//车信度得分
      tpfCreditInvestigationVO.setSocialsecuritystatus("");//社保情况
      if (StringUtils.isNotEmpty(orderCustomerVO.getCityCode())){
         String transactioncity = "";
         QueryWrapper<Area> wrapper = new QueryWrapper<>();
         HashMap<String, Object> map = new HashMap<>();
         map.put("TYPE",0);
         map.put("CODE",orderCustomerVO.getCityCode());
         wrapper.allEq(map);
         List<Area> list = areaService.list(wrapper);
         if (list!=null&&list.size()>0){
            transactioncity = list.get(0).getName();
         }
         tpfCreditInvestigationVO.setTransactioncity(transactioncity);
      }
      tpfCreditInvestigationVO.setTransactiontime("");//意向购车时间
      tpfCreditInvestigationVO.setAddress(customerCreditFinancialPlanVO.getResidentialAddress());//居住地址
      tpfCreditInvestigationVO.setProvince(customerCreditFinancialPlanVO.getResidentialProvince());//居住省
      tpfCreditInvestigationVO.setCity(customerCreditFinancialPlanVO.getResidentialCity());//居住地级市
      tpfCreditInvestigationVO.setResidenceprovince("");//户籍省
      tpfCreditInvestigationVO.setRedidencecity("");//户籍市
      tpfCreditInvestigationVO.setCompanyname(customerCreditFinancialPlanVO.getCompanyName());//单位名称
      tpfCreditInvestigationVO.setCompanyaddress(customerCreditFinancialPlanVO.getCompanyAddress());//单位地址
      tpfCreditInvestigationVO.setCompanyprovince(customerCreditFinancialPlanVO.getCompanyProvince());//单位所在省
      tpfCreditInvestigationVO.setCompanycity(customerCreditFinancialPlanVO.getCompanyCity());//单位所在地级市
      tpfCreditInvestigationVO.setMainincome(customerCreditFinancialPlanVO.getIncomeAfterTax());//主要税后年收入
      tpfCreditInvestigationVO.setMaritalstatus(customerCreditFinancialPlanVO.getMarriage());//婚姻状况
      tpfCreditInvestigationVO.setSpousename(customerCreditFinancialPlanVO.getSpouseName());//配偶名
      tpfCreditInvestigationVO.setSpousemobile(customerCreditFinancialPlanVO.getSpousePhone());//配偶手机
      tpfCreditInvestigationVO.setSpouseid(customerCreditFinancialPlanVO.getSpouseCertNo());//配偶身份证
      tpfCreditInvestigationVO.setUrgencyname(customerCreditFinancialPlanVO.getEmergencyContact());//紧急联系人
      tpfCreditInvestigationVO.setUrgencyrelation(customerCreditFinancialPlanVO.getEmergencyContactRelation());//与紧急联系人关系
      tpfCreditInvestigationVO.setUrgencymobile(customerCreditFinancialPlanVO.getEmergencyContactPhone());
      tpfCreditInvestigationVO.setLicenseprovince("");//上牌省
      tpfCreditInvestigationVO.setLicensecity("");//上牌地级市
      return tpfCreditInvestigationVO;
   }

   /**
    * 设置金融方案信息
    * @param customerCreditFinancialPlanVO
    * @param customCreditReporting
    */
   private void setFinInfo(CustomerCreditFinancialPlanVO customerCreditFinancialPlanVO,OrderCustomerVO orderCustomerVO, CustomCreditReporting customCreditReporting) {
      customCreditReporting.setCreditCode(customerCreditFinancialPlanVO.getAuditNo());//审核流水号
      customCreditReporting.setLeadsid(customerCreditFinancialPlanVO.getOrderNo());//订单号
      customCreditReporting.setPaymentType(customerCreditFinancialPlanVO.getPaymentType());//支付方式 1.全款2.分期

      customCreditReporting.setIsLicense(customerCreditFinancialPlanVO.getHasLicence());//是否自备牌照

      if ("1".equals(customerCreditFinancialPlanVO.getAuditType())){
         customCreditReporting.setName(customerCreditFinancialPlanVO.getUserName());//姓名
         customCreditReporting.setGender(customerCreditFinancialPlanVO.getGender());//性别
         customCreditReporting.setPhone(customerCreditFinancialPlanVO.getPhoneNo());//手机号码
         if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getCertType())){
            customCreditReporting.setIdCertType(Integer.valueOf(customerCreditFinancialPlanVO.getCertType()));//证件类型
         }
         customCreditReporting.setIdCertNo(customerCreditFinancialPlanVO.getCertNo());//证件号码
         customCreditReporting.setProvince(customerCreditFinancialPlanVO.getResidentialProvince());//居住省
         customCreditReporting.setCity(customerCreditFinancialPlanVO.getResidentialCity());//居住市
         customCreditReporting.setAddr(customerCreditFinancialPlanVO.getResidentialAddress());//居住地址
         customCreditReporting.setResidenceprovince(customerCreditFinancialPlanVO.getAddress());//户口所在地
         if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getMarriage())){
            customCreditReporting.setMaritalStatus(Integer.valueOf(customerCreditFinancialPlanVO.getMarriage()));//婚姻状况
         }
         customCreditReporting.setEducation(customerCreditFinancialPlanVO.getEducation());//学历
         customCreditReporting.setEmployerName(customerCreditFinancialPlanVO.getCompanyName());//单位名称
         customCreditReporting.setEmployerAddr(customerCreditFinancialPlanVO.getCompanyAddress());//单位地址
         customCreditReporting.setCompanycity(customerCreditFinancialPlanVO.getCompanyCity());//单位所在市
         customCreditReporting.setCompanyprovince(customerCreditFinancialPlanVO.getCompanyProvince());//单位所在省
         customCreditReporting.setEmergencyContact(customerCreditFinancialPlanVO.getEmergencyContact());//紧急联系人姓名
         customCreditReporting.setEmergencyContactPhone(customerCreditFinancialPlanVO.getEmergencyContactPhone());//紧急联系人电话
         customCreditReporting.setUrgencyrelation(customerCreditFinancialPlanVO.getEmergencyContactRelation());//与紧急联系人关系
         customCreditReporting.setPropertystatus(customerCreditFinancialPlanVO.getResidentialStatus());//居住状况
         customCreditReporting.setMainincome(customerCreditFinancialPlanVO.getIncomeAfterTax());//主要税后年收入
         customCreditReporting.setSpouseName(customerCreditFinancialPlanVO.getSpouseName());//配偶名
         customCreditReporting.setSpousePhone(customerCreditFinancialPlanVO.getSpousePhone());//配偶手机
         customCreditReporting.setSpouseCertNo(customerCreditFinancialPlanVO.getSpouseCertNo());//配偶身份证
      }


      customCreditReporting.setIdImgPath1(customerCreditFinancialPlanVO.getIdCardPicFront());//身份证正面照片
      customCreditReporting.setIdImgPath2(customerCreditFinancialPlanVO.getIdCardPicBack());//身份证反面照片
      customCreditReporting.setLicenseImgPath1(customerCreditFinancialPlanVO.getDrivingLicensePicFront());//驾驶证正面照片
      customCreditReporting.setLicenseImgPath2(customerCreditFinancialPlanVO.getDrivingLicensePicBack());//驾驶反面证照片

      if ("2".equals(customerCreditFinancialPlanVO.getAuditType())){
         customCreditReporting.setCompany(customerCreditFinancialPlanVO.getEnterpriseName());//公司名称
         customCreditReporting.setCompanyCode(customerCreditFinancialPlanVO.getEnterpriseCode());//公司企业代码
         customCreditReporting.setCompanyPhone(customerCreditFinancialPlanVO.getEnterprisePhone());//公司固话
         customCreditReporting.setCompanytype(customerCreditFinancialPlanVO.getEnterpriseType());//企业性质(国有企业、外资企业、小微企业、上市民营企业、非上市民营企业、政府机关、事业单位、知名跨国公司、个体户、自由职业及其他)
         customCreditReporting.setCompanyLinkName(customerCreditFinancialPlanVO.getContactPerson());//联系人姓名
         customCreditReporting.setCompanyLinkPhone(customerCreditFinancialPlanVO.getContactPhone());//联系电话
         customCreditReporting.setCompanyAddr(customerCreditFinancialPlanVO.getBusinessAddress());//办公地址
         customCreditReporting.setCompanyLegalPerson(customerCreditFinancialPlanVO.getLegalRepresentative());//法定代表人
         customCreditReporting.setTaxpayerType(customerCreditFinancialPlanVO.getTaxpayerType());//纳税人类型
         customCreditReporting.setInvoiceTitle(customerCreditFinancialPlanVO.getInvoice());//发票抬头
         customCreditReporting.setTaxNo(customerCreditFinancialPlanVO.getTaxpayerNo());//纳税人识别号
         customCreditReporting.setDepositBank(customerCreditFinancialPlanVO.getInvoiceBank());//发票开户行
         customCreditReporting.setBankCardNo(customerCreditFinancialPlanVO.getInvoiceAccount());//发票开户账号
         customCreditReporting.setInvoiceAdd(customerCreditFinancialPlanVO.getInvoiceAddress());//开票地址
         customCreditReporting.setInvoiceTel(customerCreditFinancialPlanVO.getInvoicePhone());//开票电话
         customCreditReporting.setInvoiceSendAdd(customerCreditFinancialPlanVO.getInvoiceSendAddress());//发票寄送地点
         customCreditReporting.setSurety(customerCreditFinancialPlanVO.getGuarantor());//担保人姓名
         customCreditReporting.setSuretyRelation(customerCreditFinancialPlanVO.getGuarantorRelation());//担保人与申请人关系
         customCreditReporting.setSuretyCertNo(customerCreditFinancialPlanVO.getGuarantorCertNo());//担保人证件号码
         customCreditReporting.setSuretyPhone(customerCreditFinancialPlanVO.getGuarantorMobile());//担保人手机号码
         customCreditReporting.setSuretyAddr(customerCreditFinancialPlanVO.getGuarantorAddress());//担保人现居住地
         customCreditReporting.setSuretyEmployerName(customerCreditFinancialPlanVO.getGuarantorCompany());//担保人单位名称
         customCreditReporting.setSuretyEmployerAddr(customerCreditFinancialPlanVO.getGuarantorCompanyAddress());//担保人工作单位地址
         customCreditReporting.setBusinessLicensePic(customerCreditFinancialPlanVO.getBusinessLicense());//营业执照
      }



      customCreditReporting.setCustomerType(customerCreditFinancialPlanVO.getAuditType());//征信审核类型 1.个人2.企业

      customCreditReporting.setFinProduct(customerCreditFinancialPlanVO.getFinanceType());//金融类型 1.金融机构2.银行分期

      customCreditReporting.setFinancingInsitution(customerCreditFinancialPlanVO.getFinanceInstitutionCode());//金融机构编号
      customCreditReporting.setFinTerm(customerCreditFinancialPlanVO.getLeasePeriod());//分期
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getDownPaymentRatio())){
         customCreditReporting.setDownPaymentRatio(Double.valueOf(customerCreditFinancialPlanVO.getDownPaymentRatio()));//首付款比例
      }
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getMarginLevel())){
         customCreditReporting.setSuretyAmountRatio(Double.valueOf(customerCreditFinancialPlanVO.getMarginLevel()));//保证金比例
      }
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getReservePriceRatio())){
         customCreditReporting.setRetentionRatio(Double.valueOf(customerCreditFinancialPlanVO.getReservePriceRatio()));//留购价比例
      }
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getReservePrice())){
         customCreditReporting.setRetentionAmount(new BigDecimal(customerCreditFinancialPlanVO.getReservePrice()));//留购价金额
      }
      if (StringUtils.isNotEmpty(customerCreditFinancialPlanVO.getTotalPrice())){
         customCreditReporting.setTransactionPrice(new BigDecimal(customerCreditFinancialPlanVO.getTotalPrice()));//总价格
      }
      customCreditReporting.setFinancingRate(customerCreditFinancialPlanVO.getRate());//利率
      customCreditReporting.setTariff(customerCreditFinancialPlanVO.getTariff());//费率
      customCreditReporting.setMonthManagePrice(customerCreditFinancialPlanVO.getMonthManagePrice());//牌照管理费
      customCreditReporting.setDiscountType(customerCreditFinancialPlanVO.getDiscountType());//贴息类型  1：百分比 2：固定金额
      customCreditReporting.setDiscountValue(customerCreditFinancialPlanVO.getDiscountValue());//贴息值
      customCreditReporting.setCompanyLegalGender(customerCreditFinancialPlanVO.getLegalGender());//法定代表人性别,1男,2女
      customCreditReporting.setCompanyLegalPhone(customerCreditFinancialPlanVO.getLegalMobile());//法定代表人手机号
      customCreditReporting.setBusinessCity(customerCreditFinancialPlanVO.getBusinessCity());//办公城市
      customCreditReporting.setGuarantorCity(customerCreditFinancialPlanVO.getGuarantorCity());//担保人现居城市
      customCreditReporting.setGuarantorCompanyCity(customerCreditFinancialPlanVO.getGuarantorCompanyCity());//担保人工作城市

      customCreditReporting.setApprovalStatus(1);
      customCreditReporting.setProductType(String.valueOf(orderCustomerVO.getBuyType()));
      customCreditReporting.setVehicleModel(orderCustomerVO.getProductPackageId());
      if (orderCustomerVO.getCreateTime()!=null){
         String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(orderCustomerVO.getCreateTime());
         customCreditReporting.setApplyTime(createTime);
      }

      String applyArea = "";
      QueryWrapper<Area> wrapper = new QueryWrapper<>();
      HashMap<String, Object> map = new HashMap<>();
      map.put("TYPE",0);
      map.put("CODE",orderCustomerVO.getProvinceCode());
      wrapper.allEq(map);
      List<Area> list = areaService.list(wrapper);
      if (list!=null&&list.size()>0){
         applyArea = list.get(0).getName();
      }
      QueryWrapper<Area> wrapper2 = new QueryWrapper<>();
      HashMap<String, Object> map2 = new HashMap<>();
      map2.put("TYPE",0);
      map2.put("CODE",orderCustomerVO.getCityCode());
      wrapper2.allEq(map2);
      List<Area> list2 = areaService.list(wrapper2);
      if (list2!=null&&list2.size()>0){
         applyArea = applyArea+"-"+list2.get(0).getName();
      }
      customCreditReporting.setApplyArea(applyArea);
   }

   private CustomCreditReportingVO setCreditProp(CustomerCreditAppVO customerCreditAppVO,OrderCustomerVO orderCustomerVO)  {
      CustomCreditReportingVO customCreditReportingVO = new CustomCreditReportingVO();
      customCreditReportingVO.setLeadsid(customerCreditAppVO.getOrderNo());
      customCreditReportingVO.setVersion(customerCreditAppVO.getVersion());
      customCreditReportingVO.setCustomerType(String.valueOf(customerCreditAppVO.getStatementType()));
      Long createdTime = customerCreditAppVO.getCreatedTime();
      if (createdTime!=null){
         Date date = new Date(createdTime);
         customCreditReportingVO.setCreateTime(date);
      }

      //个人信息
      if ("1".equals(customCreditReportingVO.getCustomerType())){
         PersonInfoApp personInfoApp = customerCreditAppVO.getPersonInfo();
         customCreditReportingVO.setPhone(personInfoApp.getMobile());
         customCreditReportingVO.setName(personInfoApp.getName());
         String region = personInfoApp.getRegion();
//         if (StringUtils.isNotEmpty(region)){
//            String[] arr = region.split(",");
//            if(arr.length==2) {
               customCreditReportingVO.setProvince(region);
//               customCreditReportingVO.setCity(arr[1]);
//            }
//         }
         customCreditReportingVO.setAddr(personInfoApp.getAddress());
         customCreditReportingVO.setIdCertType(1);


         customCreditReportingVO.setIdCard(personInfoApp.getIdCard());
         customCreditReportingVO.setIdImgPath1(personInfoApp.getFrontIdPicUrl());
         customCreditReportingVO.setIdImgPath2(personInfoApp.getEndIdPicUrl());
         customCreditReportingVO.setLicenseImgPath1(personInfoApp.getMainDriverLicensePic());
         customCreditReportingVO.setLicenseImgPath2(personInfoApp.getAttachedDriverLicensePic());
      }else {
         CompanyInfoApp companyInfoApp = customerCreditAppVO.getCompanyInfo();
         customCreditReportingVO.setCompany(companyInfoApp.getCompanyName());
         customCreditReportingVO.setCompanyLinkName(companyInfoApp.getContactName());
         customCreditReportingVO.setCompanyLinkPhone(companyInfoApp.getContactPhone());
         customCreditReportingVO.setCompanyLinkPosition(companyInfoApp.getContactPosition());

         String region = companyInfoApp.getRegion();
//         if (StringUtils.isNotEmpty(region)){
//            String[] arr = region.split(",");
//            if(arr.length==2){
               customCreditReportingVO.setProvince(region);
//               customCreditReportingVO.setCity(arr[1]);
//            }
//         }
         customCreditReportingVO.setAddr(companyInfoApp.getAddress());
         customCreditReportingVO.setTaxNo(companyInfoApp.getTaxNo());
         customCreditReportingVO.setCompanyPhone(companyInfoApp.getCompanyPhone());
         customCreditReportingVO.setDepositBank(companyInfoApp.getDepositBank());
         customCreditReportingVO.setBankCardNo(companyInfoApp.getBankCardNo());
         customCreditReportingVO.setBusinessLicensePic(companyInfoApp.getBusinessLicensePicUrl());
      }


      if (orderCustomerVO!=null){
         if (orderCustomerVO.getBuyType()!=null){
            customCreditReportingVO.setProductType(String.valueOf(orderCustomerVO.getBuyType()));
         }
         customCreditReportingVO.setVehicleModel(orderCustomerVO.getProductPackageId());
         if (orderCustomerVO.getCreateTime()!=null){
            String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(orderCustomerVO.getCreateTime());
            customCreditReportingVO.setApplyTime(createTime);
         }

         String applyArea = "";
         QueryWrapper<Area> wrapper = new QueryWrapper<>();
         HashMap<String, Object> map = new HashMap<>();
         map.put("TYPE",0);
         map.put("CODE",orderCustomerVO.getProvinceCode());
         wrapper.allEq(map);
         List<Area> list = areaService.list(wrapper);
         if (list!=null&&list.size()>0){
            applyArea = list.get(0).getName();
         }
         QueryWrapper<Area> wrapper2 = new QueryWrapper<>();
         HashMap<String, Object> map2 = new HashMap<>();
         map2.put("TYPE",0);
         map2.put("CODE",orderCustomerVO.getCityCode());
         wrapper2.allEq(map2);
         List<Area> list2 = areaService.list(wrapper2);
         if (list2!=null&&list2.size()>0){
            applyArea = applyArea+"-"+list2.get(0).getName();
         }
         customCreditReportingVO.setApplyArea(applyArea);
      }

      customCreditReportingVO.setApprovalStatus(1);
      customCreditReportingVO.setFinProduct("1");
      return customCreditReportingVO;
   }

   private CustomCreditReportingVO setCustomCreditReportingVO(CustomerCreditVO customerCreditVO) {
      CustomCreditReportingVO customCreditReportingVO = new CustomCreditReportingVO();
      customCreditReportingVO.setCreditId("");
      customCreditReportingVO.setCreditCode("");
      customCreditReportingVO.setName(customerCreditVO.getName());//姓名
      customCreditReportingVO.setPhone(customerCreditVO.getMobilenumber());//手机
      customCreditReportingVO.setIdCard(customerCreditVO.getIdentitynumber());//身份证
      customCreditReportingVO.setCreateTime(new Date());
      customCreditReportingVO.setUpdateTime(new Date());
      customCreditReportingVO.setCreateBy("");
      customCreditReportingVO.setMemo("");
      customCreditReportingVO.setIsDel(0);
      customCreditReportingVO.setStatus(0);
      customCreditReportingVO.setApprovalStatus(1);
      customCreditReportingVO.setIdImgPath1("");
      customCreditReportingVO.setIdImgPath2("");
      customCreditReportingVO.setLicenseImgPath1("");
      customCreditReportingVO.setLicenseImgPath2("");
      customCreditReportingVO.setGender(customerCreditVO.getGender());
      if (StringUtils.isNotEmpty(customerCreditVO.getMaritalstatus())) {
         customCreditReportingVO.setMaritalStatus(Integer.valueOf(customerCreditVO.getMaritalstatus()));
      }
      customCreditReportingVO.setIdCertType(0);
      customCreditReportingVO.setIdCertNo("");
      customCreditReportingVO.setAddr(customerCreditVO.getAddress());//居住地址
      customCreditReportingVO.setEmployerName(customerCreditVO.getCompanyname());//单位名称
      customCreditReportingVO.setEmployerAddr(customerCreditVO.getCompanyaddress());//单位地址
      customCreditReportingVO.setEmergencyContact("");
      customCreditReportingVO.setRelation("");
      customCreditReportingVO.setEmergencyContactPhone(customerCreditVO.getUrgencymobile());//紧急联系人手机
      customCreditReportingVO.setSpouseName(customerCreditVO.getSpousename());//配偶名
      customCreditReportingVO.setSpousePhone(customerCreditVO.getSpousemobile());//配偶手机
      customCreditReportingVO.setSpouseCertNo(customerCreditVO.getSpouseid());//配偶身份证
      customCreditReportingVO.setSpouseAddr("");
      customCreditReportingVO.setSpouseEmployerName("");
      customCreditReportingVO.setSpouseEmployerAddr("");
      customCreditReportingVO.setCompany("");
      customCreditReportingVO.setCompanyPhone("");
      customCreditReportingVO.setCompanyLinkPhone("");
      customCreditReportingVO.setCompanyAddr("");
      customCreditReportingVO.setCompanyLegalPerson("");
      customCreditReportingVO.setCompanyLegalGender("");
      customCreditReportingVO.setCompanyLegalPhone("");
      customCreditReportingVO.setBillingInfo("");
      customCreditReportingVO.setSurety("");
      customCreditReportingVO.setSuretyRelation("");
      customCreditReportingVO.setSuretyPhone("");
      customCreditReportingVO.setSuretyCertNo("");
      customCreditReportingVO.setSuretyAddr("");
      customCreditReportingVO.setSuretyEmployerName("");
      customCreditReportingVO.setSuretyEmployerAddr("");
      customCreditReportingVO.setCompanyEmergencyContact(customerCreditVO.getUrgencyname());//紧急联系人
      customCreditReportingVO.setCompanyRelation("");
      customCreditReportingVO.setCompanyEmergencyPhone("");
      customCreditReportingVO.setFinancingInsitution("");
      customCreditReportingVO.setProductType("");
      customCreditReportingVO.setApplyTime("");
      customCreditReportingVO.setVehicleModel("");
      customCreditReportingVO.setVehiclePrice(new BigDecimal("0"));
      customCreditReportingVO.setApplyArea("");
      customCreditReportingVO.setBankReordPath(customerCreditVO.getBankslip());//银行流水
      customCreditReportingVO.setPremisesPermitPath1("");
      customCreditReportingVO.setPremisesPermitPath2("");
      customCreditReportingVO.setAuditResult("");
      customCreditReportingVO.setTransactionPrice(new BigDecimal("0"));
      customCreditReportingVO.setAcessoryBag("");
      customCreditReportingVO.setGpsPrice(new BigDecimal("0"));
      if (StringUtils.isNotEmpty(customerCreditVO.getFinAmount())) {
         customCreditReportingVO.setContractPrice(new BigDecimal(customerCreditVO.getFinAmount()));//融资金额
      }
      customCreditReportingVO.setDownPaymentRatio(0.00);
      customCreditReportingVO.setSuretyAmountRatio(0.00);
      customCreditReportingVO.setSuretyAmount(new BigDecimal("0"));
      customCreditReportingVO.setRetentionRatio(0.00);
      customCreditReportingVO.setRetentionAmount(new BigDecimal("0"));
      customCreditReportingVO.setLeaseTerm("");
      customCreditReportingVO.setFinancingPrincipal(new BigDecimal("0"));
      customCreditReportingVO.setFinancingRate("");
      customCreditReportingVO.setRentCarNoPrice(new BigDecimal("0"));
      customCreditReportingVO.setMonthlyRent(new BigDecimal("0"));
      customCreditReportingVO.setDownPayment(new BigDecimal("0"));
      customCreditReportingVO.setEndTime(new Date());
      customCreditReportingVO.setStartTime(new Date());
      customCreditReportingVO.setLeadsid(customerCreditVO.getLeadsid());//订单编号
      customCreditReportingVO.setSourceType(customerCreditVO.getSourceType());//渠道源
      customCreditReportingVO.setVehiclebrand(customerCreditVO.getVehiclebrand());//车品牌
      customCreditReportingVO.setVehiclemodelid(customerCreditVO.getVehiclemodelid());//车型id
      customCreditReportingVO.setVehiclemsrp(customerCreditVO.getVehiclemsrp());//指导价
      customCreditReportingVO.setVehicletype(customerCreditVO.getVehicletype());//车系
      customCreditReportingVO.setVehicleStatus(customerCreditVO.getType());//车辆状态
      customCreditReportingVO.setAdviceamount(customerCreditVO.getAdviceamount());//建议额度
      customCreditReportingVO.setAgerange(customerCreditVO.getAgerange());//车龄
      customCreditReportingVO.setCompanytype(customerCreditVO.getCompanytype());//企业类型
      customCreditReportingVO.setCreditcardstatus(customerCreditVO.getCreditcardstatus());//信用卡情况
      customCreditReportingVO.setDebtcardstatus(customerCreditVO.getDebtcardstatus());//银行卡情况
      customCreditReportingVO.setDelqstatus(customerCreditVO.getDelqstatus());//逾期情况
      customCreditReportingVO.setDocumentuploading(customerCreditVO.getDocumentuploading());//用户资料是否上传
      customCreditReportingVO.setFinProduct(customerCreditVO.getFinProduct());//金融产品
      customCreditReportingVO.setFinTerm(customerCreditVO.getFinTerm());//分期情况
      customCreditReportingVO.setImagepath(customerCreditVO.getImagepath());//图像相对路径
      customCreditReportingVO.setIntention(customerCreditVO.getIntention());//客户意愿
      customCreditReportingVO.setLeadschannel(customerCreditVO.getLeadschannel());//渠道
      customCreditReportingVO.setLeadstime(customerCreditVO.getLeadstime());//订单创建时间
      customCreditReportingVO.setMortgagestatus(customerCreditVO.getMortgagestatus());//房贷情况
      customCreditReportingVO.setPropertystatus(customerCreditVO.getPropertystatus());//住房情况
      customCreditReportingVO.setResidencystatus(customerCreditVO.getResidencystatus());//户口
      customCreditReportingVO.setSalary(customerCreditVO.getSalary());//月薪
      customCreditReportingVO.setScore(customerCreditVO.getScore());//车信度得分
      customCreditReportingVO.setSocialsecuritystatus(customerCreditVO.getSocialsecuritystatus());//社保情况
      customCreditReportingVO.setTransactioncity(customerCreditVO.getTransactioncity());
      customCreditReportingVO.setTransactiontime(customerCreditVO.getTransactiontime());//意向购车时间
      customCreditReportingVO.setProvince(customerCreditVO.getProvince());//居住省
      customCreditReportingVO.setCity(customerCreditVO.getCity());//居住地级市
      customCreditReportingVO.setResidenceprovince(customerCreditVO.getResidenceprovince());//户籍省
      customCreditReportingVO.setRedidencecity(customerCreditVO.getRedidencecity());//户籍市
      customCreditReportingVO.setCompanyprovince(customerCreditVO.getCompanyprovince());//单位所在省
      customCreditReportingVO.setCompanycity(customerCreditVO.getCompanycity());//单位所在地级市
      customCreditReportingVO.setMainincome(customerCreditVO.getMainincome());//主要税后年收入
      customCreditReportingVO.setUrgencyrelation(customerCreditVO.getUrgencyrelation());//与紧急联系人关系
      customCreditReportingVO.setLicenseprovince(customerCreditVO.getLicenseprovince());//上牌省
      customCreditReportingVO.setLicensecity(customerCreditVO.getLicensecity());//上牌地级市
      return customCreditReportingVO;
   }
}
